home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.object,comp.lang.c++,comp.lang.java
- Path: night.primate.wisc.edu!aplcenmp!hall
- From: hall@aplcenmp.apl.jhu.edu (Marty Hall)
- Subject: Re: Java: What's the Big Deal?
- Message-ID: <Dp757r.K5@aplcenmp.apl.jhu.edu>
- Organization: JHU/APL Research Center, Hopkins P/T CS Faculty
- References: <4jk4ee$7ri@newsbf02.news.aol.com> <1996Apr1.155416.12816@schbbs.mot.com>
- Date: Mon, 1 Apr 1996 18:40:39 GMT
-
- In article <1996Apr1.155416.12816@schbbs.mot.com> shang@corp.mot.com writes:
- >
- >The more a program depends on GC, the more likely it will exhaust memory;
- >because the storage is collected only when all its references are
- >no longer valid, not at the time when all its references are no longer
- >used.
- [...]
- >The more a language depends on GC, the more likely its application will
- >exhaust memory [...]
-
- One could also claim just the opposite: "A program/language that
- doesn't use GC is more likely to exhaust memory because of memory
- leaks". I could cite anecdotes of Lisp/Scheme/Smalltalk/Dylan vs C/C++
- applications where this is true, but of course in practice there are
- also plenty of counter-examples where using a particular garbage
- collection algorithm does in fact increase your memory requirements.
-
- >because the storage is collected only when all its references are
- >no longer valid, not at the time when all its references are no longer
- >used. Be careful, never make a variable's lifetime unecessarily longer
- >than the required.
-
- Surely this advice is true in a non-GC system also? Ie to avoid
- dangling pointers it is a good idea to get rid of references to the
- memory before you free it. Then the question becomes: "If you forget
- to get rid of all those references, is it better to have extra memory
- used as a result, or to risk dangling pointer errors?".
-
- >With Java's array, memory will be smashed into millions of small
- >pieces.
-
- There are also plenty of arguments that GC decreases the average
- overall fragmentation in real programs and that allocators in GC'd
- systems will be faster. Just as I don't buy the above argument as
- showing anything typical, I don't buy the "GC decreases fragmentation"
- argument either. Perhaps, but I'm not sure very many people know
- enough about the typical memory allocation/deallocation patterns in
- "real" programs to be able to tell.
-
- IMHO, the evidence so far suggests that expert handcrafted memory
- management and GC should have similar performance on the average. I'll
- take the GC for convenience sake (and because I may not be an expert
- at handcrafting memory management). But many situations are not
- "average". Also note that having GC in a language does not prevent you
- from managing your own memory anyhow (reusing resources, etc).
-
- However, I'm no GC expert. A few sources to read from those who are:
-
- A) Paul Wilson's survey of uniprocessor GC techniques. To appear in
- ACM's Computing Surveys:
- http://www.apl.jhu.edu/~hall/text/Papers/Bigger-GC-Survey.ps
- Also on ftp://ftp.cs.utexas.edu/pub/garbage/bigsurv.ps
- IMHO, this is the best single place to start for people (like me :-)
- who don't know much about GC but want to learn more.
-
- B) Henry Baker's paper archive:
- ftp://ftp.netcom.com/pub/hb/hbaker/home.html
-
- C) Articles by Hans-J Boehm at ftp://parcftp.xerox.com/pub/gc/. Eg
- 1) ftp://parcftp.xerox.com/pub/gc/example.html --
- A discussion showing that in some cases explicit allocation/deallocation
- (malloc/free) can be computationally more expensive than garbage
- collection. Note that he is not claiming that GC is faster in
- practice, only refuting the claim that it *must* be slower.
- 2) ftp://parcftp.xerox.com/pub/gc/complexity.html. Discusses the
- complexity of mark-sweep vs. copying garbage collectors.
- He attempts to refute the claims that copying collectors have
- better paging performance due to compaction, and that the
- asymptotic time complexity of copying collectors is necessarily
- better.
-
- Cheers-
- - Marty
- (proclaim '(inline skates))
- http://www.apl.jhu.edu/~hall
-